﻿using System;

namespace SKQMSLib
{
    public struct OperationOnUnknown
    {
        public char operation;
        public double value;

        public OperationOnUnknown(char op, double val)
        {
            operation = op;
            value = val;
        }
    }

    public class Operations 
    {
        private char[] operations = { '^', '/', '*', '+', '-' };
        private int index;

        public Operations()
        {
            index = 0;
        }

        public bool Next()
        {
            if (index < operations.Length - 1)
            {
                index++;
                return true;
            }
            else
                return false;
        }

        public char Get()
        {
            return operations[index];
        }

        public void Reset()
        {
            index = 0;
        }
    }

    public static class CheckIf
    {
        public static bool IsNumber(char character)
        {
            if (character > 47 && character < 58) return true;
            return false;
        }

        public static bool IsLetter(char character)
        {
            if (character > 64 && character < 91) return true;
            if (character > 96 && character < 123) return true;
            return false;
        }
        
        public static bool IsOutOfBounds(double number)
        {
            if (number > 0)
            {
                if (number > 1125899906842624) return true;
                if (number < 0.0001) return true; 
            }
            if (number < 0) 
            {
                if (number < -1125899906842624) return true;
                if (number > -0.0001) return true;
            }
            return false;
        }
    }

    //exceptions
    public class InvalidSignPositionException : ApplicationException
    {
        public InvalidSignPositionException(string param) : base(param) { }
    }

    public class UnkownCharacterException : ApplicationException
    {
        public UnkownCharacterException(string param) : base(param) { }
    }

    public class NumberOutOfBoundsException : ApplicationException
    {
        public NumberOutOfBoundsException(string param) : base(param) { }
    }

    public class ParenthesisException : ApplicationException
    {
        public ParenthesisException(string param) : base(param) { }
    }

    public class UnknownRelatedException : ApplicationException
    {
        public UnknownRelatedException(string param) : base(param) { }
    }
}